package com.doubi.controller.common;

import com.doubi.common.config.jwt.JwtException;
import com.doubi.constants.SystemConstants;
import com.doubi.utils.DataUtil;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;

import javax.servlet.http.HttpServletRequest;

@Validated
@CrossOrigin
public class BaseController {
    @Autowired
    private HttpServletRequest request;
    /**
     * api获取当前登录用户ID
     */
    protected String getUserOid() {
        Object o = request.getAttribute(SystemConstants.SESSION_KEY_USERINFO);
        if(DataUtil.isEmpty(o)){
            return null;
        }else {
            return o.toString();
        }
    }
}
